package com.example.couponprovider.tcc;

import com.example.couponprovider.domain.Coupon;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

/**
 * @author Kong
 * @date 2021-9-15 14:39
 */
@LocalTCC
public interface ICouponAction {
    /**
     * prepare阶段
     * @param businessActionContext
     * @param coupon
     * @return
     */
    @TwoPhaseBusinessAction(name = "couponAction")
    boolean prepareCreateOrder(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "coupon")Coupon coupon);

    /**
     * 二阶段提交
     * @param businessActionContext
     * @return
     */
    boolean commit(BusinessActionContext businessActionContext);

    /**
     * 二阶段回滚
     * @param businessActionContext
     * @return
     */
    boolean rollback(BusinessActionContext businessActionContext);
}
